#ifndef SERVICE_PTR_H
#define SERVICE_PTR_H

#include "smart_car_services.h"
#include "smart_car_service_registry.h"

namespace utils
{
	template<typename SERVICE>
	class service_ptr
	{
	public:

		service_ptr():
			service(
			    smart_car::service_registry::instance().find(
			        static_cast<smart_car::smart_car_services>(SERVICE::service_id)))
		{}

		SERVICE* operator ->()
		{
			return static_cast<SERVICE*>(service);
		}

		bool is_valid()
		{
			return (service != NULL);
		}

	private:
		smart_car::service_interface* service;
	};
}
#endif